package com.lecture.javamode.singleton;

import java.lang.reflect.Constructor;

public class SingletonTest {
    public static void main(String[] args) {
        try {
            Singleton instance = Singleton.getInstance();
            instance.print();
            Singleton instance2 = Singleton.getInstance();
            instance2.print();
            System.out.println(instance);
            System.out.println(instance2);
            Constructor<Singleton> constructor = Singleton.class.getDeclaredConstructor();
            constructor.setAccessible(true);
            Singleton singleton = constructor.newInstance();
            singleton.print();
            System.out.println(singleton);


        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
